package com.ee.chat.admin.controller.auditmanage;

import com.ee.chat.admin.service.ICreditExchangeService;
import com.ee.chat.common.bean.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("audit/creditExchange")
public class CreditExchangeController {
    private Logger log = LoggerFactory.getLogger(CreditExchangeController.class);

    @Resource
    ICreditExchangeService CreditExchangeService;

    /**
     * 积分兑换审核列表
     * @Author Shane
     * @Date 2019/10/9 23:43
     * @param
     * @return
     */
    @RequestMapping("list")
    public Result list(HttpServletRequest request, @RequestParam Integer page, @RequestParam Integer limit,
                       Integer userId, Integer status, String createTime){
        try {
            return CreditExchangeService.list(request, page, limit, userId, status, createTime);
        } catch (Exception e){
            log.error("【获取积分审核列表错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 积分兑换审核
     * @Author Shane
     * @Date 2019/10/10 0:47
     * @param id        认证记录id
     * @param status    审核状态，1-通过  2-拒绝
     * @return
     */
    @RequestMapping("audit")
    public Result audit(HttpServletRequest request, @RequestParam Integer id, @RequestParam Integer status, String reason){
        try {
            return CreditExchangeService.audit(request, id, status, reason);
        } catch (Exception e){
            log.error("【积分兑换证审核错误】", e);
        }
        return Result.returnFailure();
    }

    /**
     * 撤销积分兑换审核
     * @Author AppiJ
     * @Date 2021/1/5 17:56
     * @param
     * @return
     */
    @RequestMapping("cancelAudit")
    public Result cancelAudit(HttpServletRequest request, @RequestParam Integer id, String reason){
        try {
            return CreditExchangeService.cancelAudit(request, id, reason);
        } catch (Exception e){
            log.error("【撤销积分兑换审核错误】", e);
        }
        return Result.returnFailure();
    }
}
